package com.example.spotitube.Controller;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.example.spotitube.R;
import com.example.spotitube.Model.Track;

/**
 * Used to display albums in a list
 * @author Jeffrey
 *
 */
public class AlbumListAdapter extends ArrayAdapter<String>{
	
	private ArrayList<String>	albums;
	private Context				context;
	
	
	public AlbumListAdapter( Context context, int textViewResourceId, ArrayList<String> albums ) {
		super( context, textViewResourceId, albums );
		this.context = context;
		this.albums = albums;
	}
	
	
	@Override
	public View getView( int position, View convertView, ViewGroup parent ) {
		LayoutInflater inflater = ( LayoutInflater ) context.getSystemService( Context.LAYOUT_INFLATER_SERVICE );
		View listItem = inflater.inflate( R.layout.list_item, parent, false );
		TextView albumName = ( TextView ) listItem.findViewById( R.id.name );
		
		String album = albums.get( position );
		albumName.setText( album );
		
		return listItem;
	}
	
	
	public ArrayList<String> getAlbums() {
		return albums;
	}
}
